package oaSystem.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import oaSystem.biz.DocumentBiz;
import oaSystem.entity.Document;
import oaSystem.mapper.DocumentMapper;
@Transactional
@Service
public class DocumentBizImpl implements DocumentBiz {
	
	@Autowired
	private DocumentMapper documentMapper;
	
	@Override
	public void addFolder(Document document) {
		documentMapper.addDocument(document);
	}

	@Override
	public void addFile(Document document) {
		documentMapper.addDocument(document);
	}

	@Override//拖拽文件夹   在controller先找到 要拖拽的文件夹 复制一份到 目标文件  然后再删除原文件
	public void moiveDocument(Document document, int parentId) {//但在数据路中只需要更改父文件夹的Id
		document.setParentId(parentId);//移动到父文件夹
		documentMapper.updateDocument(document);
	}

	@Override//批量删除
	public void deleteFile(List<Integer> documentId) {//遍历选中的documentId
		for (Integer deleteId : documentId) {
			documentMapper.deleteDocument(deleteId);
		}
	}

	@Override
	public void download(int documentId) {
		//
	}

	@Override//查询所有
	public List<Document> findAllDocment() {
		return documentMapper.findAllDocument();
	}

	@Override
	public Document fetchDocmentById(int documentId) {
		return documentMapper.fetchDocumentById(documentId);
	}

	@Override
	public List<Document> findByParentId(int parentId) {
		return documentMapper.findByParentId(parentId);
	}
	
}
